<?php
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'make-query-grid',
    'dataProvider' => $model->search(),
    'filter' => $model,
    'summaryText'=>'NoData',
    'columns' => array(
        array(
            'header' => 'Trainer Name',
            'name' => 'classes_id',
            'type' => 'raw',
            'value' => 'MakeQuery::getTrainerName($data)',
            'filter' => FALSE,
        ),
        // 'phone',
        
        array(
            'header' => 'Class/Course Name',
            'name' => 'classes_id',
            'type' => 'raw',
            'value' => 'MakeQuery::classCoursename($data)',
            'filter' => FALSE,
        ),
        array(
            'name' => 'users_id',
            'header' => 'Query By',
            'value' => 'GxHtml::valueEx($data->users)',
            'filter' => GxHtml::listDataEx(Users::model()->findAllAttributes(null, true)),
        ),
//        array(
//            'name' => 'is_converted',
//            'type' => 'raw',
//            'value' => '$data->is_converted==null ? "No" : "Yes"',
//            'filter' => array('is NULL' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),
//        ),
        array(
            'header' => 'Responded',
            'name' => 'mail_sent',
            'type' => 'raw',
            'value' => '$data->mail_sent==null ? MakeQuery::mailToTrainerreminderLink($data): "Yes"',
            'filter' => array('is NULL' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),
        ),
        array(
            'header' => 'Create Time',
            'name' => 'created',
            'type' => 'raw',
            'value' => '$data->created',
        ),
       
        array(
            'class' => 'CButtonColumn',
            'template' => '{QueryDeatils}',
            //--------------------- begin new code --------------------------
            'buttons' => array(
                'QueryDeatils' =>
                array(
                    'url' => '$this->grid->controller->createUrl("queryDeatils", array("id"=>$data->primaryKey,"asDialog"=>1,"gridId"=>$this->grid->id))',
                    'click' => 'function(){$("#cru-frame").attr("src",$(this).attr("href")); $("#cru-dialog").dialog("open");  return false;}',
                ),
            ),
        //--------------------- end new code --------------------------
        ),
    ),
));
?>


<?php
//--------------------- begin new code --------------------------
// add the (closed) dialog for the iframe
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
    'id' => 'cru-dialog',
    'options' => array(
        'title' => 'View Query Deatils',
        'autoOpen' => false,
        'modal' => false,
        'width' => 850,
        'height' => 450,
    ),
));
?>
<iframe id="cru-frame" width="100%" height="100%"></iframe>
<?php
$this->endWidget();
//--------------------- end new code --------------------------
?>
<style>
    .row-fluid .span9 {
        width: 95%;
        margin: 0 auto;
    }</style>
<script>
    function remindtoTrainer(classId,courseId,queryid) {
        $.ajax({
            'type': 'POST',
            'url': "<?php echo Yii::app()->createAbsoluteUrl("makeQuery/remindtoTrainer"); ?>",
            'data': "classId=" + classId+ "&courseId=" + courseId+ "&queryid=" + queryid,
           
            'success': function(data) {
                if($.trim(data)=='success') {                    
                    alert('You have Remind This trainer.')
                }
            },
            'cache': false
        });
    }


</script>